package com.wego.common.ex;

import com.wego.common.enumeration.ResultEnum;

/**
 * 自定义全局异常类
 * @author: hc
 * @date: 2023/7/5
 */
public class GlobalException extends RuntimeException {
    /**
     * 异常错误编码
     */
    private Integer code;

    /**
     * 异常信息
     */
    private String msg;

    /**
     * 生成异常时页面的url
     */
    private String url;

    public GlobalException() {
    }

    public GlobalException(ResultEnum resultEnum) {
        this.code = resultEnum.code();
        this.msg = resultEnum.msg();
    }

    public GlobalException(ResultEnum resultEnum, String url) {
        this.code = resultEnum.code();
        this.msg = resultEnum.msg();
        this.url = url;
    }

    public GlobalException(Integer code, String msg, String url) {
        this.code = code;
        this.msg = msg;
        this.url = url;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return "GlobalException{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", url='" + url + '\'' +
                '}';
    }
}
